package fic.storefinder.server.updateservice.updatechecker;

import java.util.HashMap;
import java.util.TreeMap;

import fic.storefinder.server.db.POITable;
import fic.storefinder.server.db.RobeTable;
import fic.storefinder.server.updateservice.ServiceInterface;
import fic.storefinder.shared.utils.Constants;

public abstract class CheckForUpdateService implements ServiceInterface {
	
	
	
	
	
	@Override
	public void setParameters(HashMap<String, Object> parameters) {
		
		
	}

	@Override
	public String generateResponse() throws Exception {
		POITable poiTable = new POITable();
		RobeTable robeTable = new RobeTable();
		long poiLastUpdateDate = poiTable.getMaxLastUpdateDate();
		long robeLastUpdateDate = robeTable.getMaxLastUpdateDate();
		Long lastUpdateDate = Math.max(poiLastUpdateDate, robeLastUpdateDate);
		HashMap<String, Long> ludHashMap = new HashMap<String, Long>();
		ludHashMap.put(Constants.JSON_KEY_LASTUPDATEDATE, lastUpdateDate);
		TreeMap<String, Object> respData = new TreeMap<String, Object>();
		respData.put(Constants.JSON_KEY_RESPONSE, ludHashMap);
		return this.formatResponse(respData);
	}
	
	
}
